package com.ag.dgm.dao;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.Session;
import com.ag.bean.TbAdviceType;
import com.ag.bean.TbPlanType;
import com.ag.common.IDUtil;

public class TbAdviceTypeDAO extends com.ag.dao.TbAdviceTypeDAO {

	private Session session;

	@Override
	public void delete(TbAdviceType persistentInstance) {
		String hql = "update TbAdviceType t set t.a=" + IDUtil.DELETE
				+ " where t.atId=" + persistentInstance.getAtId();
		session = (Session) this.getSessionFactory().openSession();
		try {
			Transaction tx = session.beginTransaction();
			Query query = session.createQuery(hql);
			int count = query.executeUpdate();
			tx.commit();
		} catch (HibernateException e) {
			System.out.println(e.toString());
		} finally {
			session.close();
		}
	}

	@Override
	public List<TbAdviceType> findAll() {
		System.out.println("这是findAllType_dao方法");
	/*	for(TbAdviceType t:super.findByA(IDUtil.PRESERVE)){
			System.out.println(t.getAtId()+"*************");
		}*/
		return super.findByA(IDUtil.PRESERVE);
	}

}
